package com.enation.app.shop.front.policyInsurance.service.impl;

import com.enation.app.shop.front.policyInsurance.entity.InsuranceCheck;
import com.enation.app.shop.front.policyInsurance.service.InsuranceCheckMapper;
import com.enation.framework.database.IDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class InsuranceCheckService implements InsuranceCheckMapper {

    @Autowired
    private IDaoSupport iDaoSupport;

    @Override
    public int insert(InsuranceCheck record) {
        this.iDaoSupport.insert("rbt_insurance_check",record);
        return 1;
    }

    @Override
    public InsuranceCheck selectByWarrantyId(Integer warranty_id) {
        String sql ="SELECT * from rbt_insurance_check c where c.warranty_id=?";
        List<InsuranceCheck> insuranceCheck= this.iDaoSupport.queryForList(sql,InsuranceCheck.class,warranty_id);
        return insuranceCheck.get(0);
    }

    public int updateByWarrantyId(int inPolicy_id, Map insCheckMap) {
        this.iDaoSupport.update("rbt_insurance_check",insCheckMap,"warranty_id="+inPolicy_id);
        return 1;
    }

    public int updateByWarrantyId(InsuranceCheck insuranceCheck) {
        this.iDaoSupport.update("rbt_insurance_check",insuranceCheck,"warranty_id="+insuranceCheck.getWarranty_id());
        return 1;
    }
}
